package org.vectrics.common.html;

import org.apache.ecs.GenericElement;
import org.apache.ecs.html.Input;
import org.apache.log4j.Logger;



public class Form  {
	private org.apache.ecs.html.Form ecsForm = new org.apache.ecs.html.Form();
	public static final String post = org.apache.ecs.html.Form.post;  
	public static final String get = org.apache.ecs.html.Form.get;  
	public static final String NO_ATTRIBUTE_VALUE = org.apache.ecs.html.Form.NO_ATTRIBUTE_VALUE;
	private Logger log = Logger.getLogger(this.getClass());

	public Form() {
    	ecsForm.setPrettyPrint(true);
    }
	
	public org.apache.ecs.html.Form getEcsForm() {
		return(this.ecsForm);
	}
	
	public void setID(String id) {
		this.ecsForm.setID(id);
	}
    
	public void setAcceptCharset(String value) {
		this.ecsForm.setAcceptCharset(value);
	}
	
	public void setEncType(String value) {
		this.ecsForm.setEncType(value);	
	}
	
    public Input addEdit() {
        Input edit = new Input();
        edit.setType(Input.TEXT);
        this.ecsForm.addElement(edit);
        return(edit);
    };

    public Input addCheckBox() {
        Input checkBox = new Input();
        checkBox.setType(Input.CHECKBOX);
        this.ecsForm.addElement(checkBox);
        return(checkBox);
    };

    public Input addSubmitButton() {
        Input button = new Input();
        button.setType(Input.SUBMIT);
        this.ecsForm.addElement(button);
        return(button);
    };

    public Input addHidden() {
        Input hidden = new Input();
        hidden.setType(Input.HIDDEN);
        this.ecsForm.addElement(hidden);
        return(hidden);
    };

    public Input addHidden(String name, String value) {
        Input hidden = addHidden();
        hidden.setName(name);
        hidden.setValue(value);
        hidden.setID(name);
        this.ecsForm.addElement(hidden);
        return(hidden);
    };

    public void addElement(String str) {
    	this.ecsForm.addElement(str);
    	//log.info("Added element - element str: " + str );
    	//log.info("Added element - current str: " + this.toString() );
    }

    public void addElement(GenericElement element) {
    	this.ecsForm.addElement(element);
    	//log.info("Added element - element str: " + element.toString());
    	//log.info("Added element - current str: " + this.toString() );
    }
    
    public void setPrettyPrint(boolean value) {
    	this.ecsForm.setPrettyPrint(value);
    }
    
    public String getAttribute(String name) {
    	return(this.ecsForm.getAttribute(name));
    }
    
	public void addAttribute(String name, String value) {
		this.ecsForm.addAttribute(name, value);
	}

    public void setAction(String action) {
    	this.ecsForm.setAction(action);
    }
    public void setMethod(String method) {
    	this.ecsForm.setMethod(method);
    }
    
    public String toString() {
    	String str = this.ecsForm.toString();
    	return(str);
    }
}